{extend name="base" /}
{block name="title"}{$ptitle|default="管理后台"}{/block}

{block name="headjs"}
    <link href="__STATICS__/css/iconpm/css/icon-picker.min.css" media="all" rel="stylesheet" type="text/css" />
{/block}

{block name="content"}
            <form id="form_data" method="post" class="form-horizontal bv-form" data-bv-message="This value is not valid" data-bv-feedbackicons-valid="glyphicon glyphicon-ok" data-bv-feedbackicons-invalid="glyphicon glyphicon-remove" data-bv-feedbackicons-validating="glyphicon glyphicon-refresh" novalidate="novalidate"><button type="submit" class="bv-hidden-submit" style="display: none; width: 0px; height: 0px;"></button>
                <div class="form-group has-feedback">
                    <label class="col-lg-3 control-label">上级菜单</label>
                    <div class="col-lg-5">
                        <select class="form-control" name="pid" data-bv-field="pid">
                            <option value="0">作为一级菜单</option>
{foreach $menus as $v}
                            <option value="{$v.id}" {if $pid==$v.id} selected="selected"{/if}>{$v.name|raw}</option>
{/foreach}
                        </select>
                    </div>
                </div>
                <div class="form-group has-feedback">
                    <label class="col-lg-3 control-label">菜单名称</label>
                    <div class="col-lg-5">
                        <input type="text" class="form-control" name="name" data-bv-field="name" value="{$menu.name|default=''}">
	                </div>
                </div>
                <div class="form-group has-feedback">
                    <label class="col-lg-3 control-label">菜单链接</label>
                    <div class="col-lg-5">
                        <input type="text" class="form-control" name="url" data-bv-field="url" value="{$menu.url|default=''}">
	                </div>
                    <div class="col-lg-4">
                        格式：模块名/控制器名/方法名，如：admin/menu/index；外部链接需带http://
	                </div>
                </div>
                <div class="form-group has-feedback">
                    <label class="col-lg-3 control-label">菜单图标</label>
                    <div class="col-lg-5">
                        <input type="text" class="form-control icon-picker" name="icon" data-bv-field="icon" value="{$menu.icon|default=''}">
	                </div>
                    <div class="col-lg-4 input_r">
                        <span>点击图标更换</span>
	                </div>
                </div>
                <div class="form-group has-feedback">
                    <label class="col-lg-3 control-label">扩展参数</label>
                    <div class="col-lg-5">
                        <input type="text" class="form-control" name="data" data-bv-field="data" value="{$menu.data|default=''}">
	                </div>
                    <div class="col-lg-4 input_r">
                        选填，参考格式：a=123&b=345
	                </div>
                </div>
                <div class="form-group has-feedback">
                    <label class="col-lg-3 control-label">状态设置</label>
                    <div class="col-lg-5">
                        <div class="control-group">
                        	<div class="col-lg-3 col-sm-3 col-xs-3">
                            	<div class="radio">
                            		<label><input class="colored-success" name="display" value="1" type="radio" {if $menu.display} checked="checked"{/if} /><span class="text"> 启用</span></label>
                            	</div>
                            </div>
                        	<div class="col-lg-3 col-sm-3 col-xs-3">
                            	<div class="radio">
                            		<label><input class="colored-danger" name="display" value="0" type="radio" {if !$menu.display} checked="checked"{/if} /><span class="text"> 禁用</span></label>
                            	</div>
                            </div>
                        </div>
	                </div>
                </div>
                <div class="form-group has-feedback">
                    <label class="col-lg-3 control-label">系统菜单</label>
                    <div class="col-lg-5">
                        <div class="control-group">
                        	<div class="col-lg-3 col-sm-3 col-xs-3">
                            	<div class="radio">
                            		<label><input class="colored-success" name="sys" value="1" type="radio" {if $menu.sys} checked="checked"{/if} /><span class="text"> 是</span></label>
                            	</div>
                            </div>
                        	<div class="col-lg-3 col-sm-3 col-xs-3">
                            	<div class="radio">
                            		<label><input class="colored-danger" name="sys" value="0" type="radio" {if !$menu.sys} checked="checked"{/if} /><span class="text"> 否</span></label>
                            	</div>
                            </div>
                        	<div class="col-lg-6 col-sm-6 col-xs-6">
                            	<div class="radio">
                            		设置为系统菜单后，无法删除
                            	</div>
                            </div>
                        </div>
	                </div>
                </div>
                <div class="form-group has-feedback">
                    <label class="col-lg-3 control-label">经典模式</label>
                    <div class="col-lg-5">
                        <div class="control-group">
                        	<div class="col-lg-3 col-sm-3 col-xs-3">
                            	<div class="radio">
                            		<label><input class="colored-success" name="jian" value="1" type="radio" {if $menu.jian} checked="checked"{/if} /><span class="text"> 显示</span></label>
                            	</div>
                            </div>
                        	<div class="col-lg-3 col-sm-3 col-xs-3">
                            	<div class="radio">
                            		<label><input class="colored-danger" name="jian" value="0" type="radio" {if !$menu.jian} checked="checked"{/if} /><span class="text"> 隐藏</span></label>
                            	</div>
                            </div>
                        	<div class="col-lg-6 col-sm-6 col-xs-6">
                            	<div class="radio">
                            		在经典模式中显示
                            	</div>
                            </div>
                        </div>
	                </div>
                </div>
                <div class="form-group has-feedback">
                    <label class="col-lg-3 control-label">新窗打开</label>
                    <div class="col-lg-5">
                        <div class="control-group">
                        	<div class="col-lg-3 col-sm-3 col-xs-3">
                            	<div class="radio">
                            		<label><input class="colored-success" name="target" value="1" type="radio" {if $menu.target} checked="checked"{/if} /><span class="text"> 是</span></label>
                            	</div>
                            </div>
                        	<div class="col-lg-3 col-sm-3 col-xs-3">
                            	<div class="radio">
                            		<label><input class="colored-danger" name="target" value="0" type="radio" {if !$menu.target} checked="checked"{/if} /><span class="text"> 否</span></label>
                            	</div>
                            </div>
                        	<div class="col-lg-6 col-sm-6 col-xs-6">
                            	<div class="radio">
                            		在新窗口还是当前窗口打开
                            	</div>
                            </div>
                        </div>
	                </div>
                </div>
                <div class="form-group has-feedback">
                    <label class="col-lg-3 control-label"></label>
                    <div class="col-lg-5">
                        <button type="submit" class="btn btn-primary" id="form_btn">提 交</button></div>
                </div>
            </form>
{/block}


{block name="footjs"}
    <script src="__STATICS__/assets/js/validation/bootstrapValidator.js?v=__VERSION__"></script>
    <script src="__STATICS__/css/iconpm/js/iconPicker.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $(".icon-picker").iconPicker();
        });
    </script>
    <script>
        $(document).ready(function () {
        	$('.icon-picker').next('span').children('i').removeClass().addClass("{$menu.icon|default='themeprimary fa fa-picture-o'}"); 
        	$('.icon-picker').next('span').children('i').css('font-size','18px'); 

    		var that = $('#form_data');
        	that.bootstrapValidator({
                excluded: [':disabled'],
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                submitHandler: function (validator, form, submitButton) {
                    // Do nothing
                },
                fields: {
                    name: {
                        validators: {
                            notEmpty: {
                                message: '请输入菜单名称'
                            }
                        }
                    },
                    url: {
                        validators: {
                            notEmpty: {
                                message: '请输入菜单链接'
                            }
                        }
                    }
                }

            }).on('success.form.bv', function(e) {
                e.preventDefault();
                var bv = that.data('bootstrapValidator');
                swpost(that.attr('action'), that.serialize(), bv);
            });


        });
    </script>
{/block}